home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / OLEWINDO.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  15KB  |  395 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1994, 1997 by Borland International, All Rights Reserved
  4. //
  5. // $Revision:   10.15  $
  6. //
  7. // TOleWindow - Class encapsulating a window which can be an OLE container
  8. //              or server window.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_OLEWINDO_H)
  11. #define OWL_OLEWINDO_H
  12.  
  13. #if !defined(OWL_WINDOW_H)
  14. # include <owl/window.h>
  15. #endif
  16. #if !defined(OWL_DC_H)
  17. # include <owl/dc.h>
  18. #endif
  19. #if !defined(OWL_OCFEVENT_H)
  20. # include <owl/ocfevent.h>
  21. #endif
  22. #if !defined(OCF_OCREMVIE_H)
  23. # include <ocf/ocremvie.h>
  24. #endif
  25. #if !defined(OCF_OCPART_H)
  26. # include <ocf/ocpart.h>
  27. #endif
  28. #if !defined(OWL_UIHELPER_H)
  29. # include <owl/uihelper.h>
  30. #endif
  31. #if !defined(OCF_OCLINK_H)
  32. # include <ocf/oclink.h>
  33. #endif
  34.  
  35. #if defined(BI_NAMESPACE)
  36. namespace OCF {
  37. #endif
  38.  
  39. #if defined(BI_PLAT_WIN32)
  40. class _ICLASS   TOcControl;
  41. #endif
  42.  
  43. #if defined(BI_NAMESPACE)
  44. } // namespace OCF
  45. #endif
  46.  
  47. #if defined(BI_NAMESPACE)
  48. namespace OWL {
  49. #endif
  50.  
  51. // Generic definitions/compiler options (eg. alignment) preceeding the
  52. // definition of classes
  53. #include <services/preclass.h>
  54.  
  55. class _OWLCLASS TPopupMenu;
  56.  
  57. //
  58. // class TOleWindow
  59. // ~~~~~ ~~~~~~~~~~
  60. // The generic OLE2 window. Use as a client of a frame window.
  61. //
  62. class _USERCLASS TOleWindow : virtual public TWindow {
  63.   public:
  64.     TOleWindow(TWindow* parent = 0, TModule* module = 0);
  65.    ~TOleWindow();
  66.  
  67.     // Accessors
  68.     //
  69.     TOcDocument*      GetOcDoc();
  70.     TOcView*          GetOcView();
  71.     TOcRemView*       GetOcRemView();
  72.     TOcApp*           GetOcApp();
  73.     bool              HasActivePart();
  74.     bool              SelectEmbedded();
  75.  
  76.     // Query about current state
  77.     //
  78.     bool              IsOpenEditing() const;
  79.     bool              IsRemote() const;
  80.  
  81.     // Virtuals that derived class can override
  82.     //
  83.     virtual bool      OleShutDown();
  84.     virtual void      SetupDC(TDC& dc, bool scale = true);
  85.     virtual TOcView*  CreateOcView(TRegLink* link, bool isRemote, IUnknown* outer);
  86.  
  87.     // Helper routines to create new objects or controls [Container specific]
  88.     //
  89.     TOcPart*          InsertObject(TOcInitInfo& initInfo, TRect* pos = 0);
  90.     TOcPart*          InsertObject(CLSID& objIID, TRect* pos = 0);
  91.     TOcPart*          InsertObject(TString& objProgId, TRect* pos = 0);
  92.  
  93. #if defined(BI_PLAT_WIN32)
  94.     TOcControl*       InsertControl(TOcInitInfo& initInfo, TRect* pos = 0, int id = 0);
  95.     TOcControl*       InsertControl(CLSID& ocxIID, TRect* pos = 0, int id = 0);
  96.     TOcControl*       InsertControl(const TString& ocxProgID, TRect* pos = 0, int id = 0);
  97. #endif
  98.  
  99.     // Helper routines to retrieve information about parts (embeddings/ocxes)
  100.     //
  101. #if defined(BI_PLAT_WIN32)
  102.     TOcControl*       GetOcControlOfOCX(CLSID ocxIID, uint id = 0);
  103. #endif
  104.  
  105.   protected:
  106.     // Overridables
  107.     //
  108.     virtual void      GetInsertPosition(TRect& rect);
  109.     virtual void      InvalidatePart(TOcInvalidate invalid); // server only
  110.     virtual bool      Deactivate();
  111.     virtual bool      Select(uint modKeys, TPoint& point);
  112.     virtual bool      PaintSelection(TDC& dc, bool erase, TRect& rect,
  113.                                      void* userData = 0);
  114.     virtual bool      PaintParts(TDC& dc, bool erase, TRect& rect, bool metafile);
  115.     virtual bool      PaintLink(TDC& dc, bool erase, TRect& rect,
  116.                                 TString& moniker);
  117.     virtual void      GetLogPerUnit(TSize& logPerUnit);
  118.     virtual void      SetScale(uint16 percent);
  119.     virtual void      SetSelection(TOcPart* part);
  120.     virtual bool      ShowCursor(HWND wnd, uint hitTest, uint mouseMsg);
  121.     virtual bool      StartDrag(uint modKeys, TPoint& point);
  122.     virtual const char* GetFileName();
  123.  
  124.   protected:
  125.     // Override virtual functions defined by TWindow
  126.     //
  127.     void              SetupWindow();
  128.     void              CleanupWindow();
  129.     bool              PreProcessMsg(MSG& msg);
  130.     bool              IdleAction(long idleCount);
  131.     bool              CanClose();
  132.  
  133.     bool              InClient(TDC& dc, TPoint& point);
  134.  
  135.     TResult           EvCommand(uint id, HWND hWndCtl, uint notifyCode);
  136.     void              EvCommandEnable(TCommandEnabler& commandEnabler);
  137.     void              EvPaint();
  138.     void              EvSize(uint sizeType, TSize& size);
  139.     void              EvMDIActivate(HWND hWndActivated, HWND hWndDeactivated);
  140.     uint              EvMouseActivate(HWND topParent, uint hitCode, uint msg);
  141.     void              EvSetFocus(HWND hWndLostFocus);
  142.  
  143.     virtual bool      EvOcViewPartInvalid(TOcPartChangeInfo& changeInfo);
  144.  
  145.     void              CeFileClose(TCommandEnabler& ce);
  146.     void              CmEditDelete();
  147.     void              CmEditCut();
  148.     void              CmEditCopy();
  149.     void              CmEditPaste();
  150.     void              CmEditPasteSpecial();
  151.     void              CmEditPasteLink();
  152.     void              CmEditLinks();
  153.     void              CmEditConvert();
  154.     void              CmEditInsertObject();
  155.  
  156. #if defined(BI_PLAT_WIN32)
  157.     void              CmEditInsertControl();
  158. #endif
  159.  
  160.     void              CmEditShowObjects();
  161.  
  162.     void              CeEditDelete(TCommandEnabler& ce);
  163.     void              CeEditCut(TCommandEnabler& ce);
  164.     void              CeEditCopy(TCommandEnabler& ce);
  165.     void              CeEditPaste(TCommandEnabler& ce);
  166.     void              CeEditPasteSpecial(TCommandEnabler& ce);
  167.     void              CeEditPasteLink(TCommandEnabler& ce);
  168.     void              CeEditLinks(TCommandEnabler& ce);
  169.     void              CeEditObject(TCommandEnabler& ce);
  170.     void              CeEditConvert(TCommandEnabler& ce);
  171.     void              CeEditVerbs(TCommandEnabler& ce);
  172.     void              CeEditInsertObject(TCommandEnabler& ce);
  173.  
  174. #if defined(BI_PLAT_WIN32)
  175.     void              CeEditInsertControl(TCommandEnabler& ce);
  176. #endif
  177.  
  178.     void              CeEditShowObjects(TCommandEnabler& ce);
  179.  
  180.     void              EvMouseMove(uint modKeys, TPoint& point);
  181.     void              EvRButtonDown(uint modKeys, TPoint& point);
  182.     void              EvLButtonUp(uint modKeys, TPoint& point);
  183.     void              EvLButtonDown(uint modKeys, TPoint& point);
  184.     void              EvLButtonDblClk(uint modKeys, TPoint& point);
  185.     bool              EvSetCursor(HWND hWndCursor, uint hitTest, uint mouseMsg);
  186.     void              EvDropFiles(TDropInfo dropInfo);
  187.     void              EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
  188.     void              EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
  189.     void              EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu);
  190.  
  191.     TResult           EvOcEvent(TParam1 param1, TParam2 param2);
  192.  
  193.     // Container specific messages
  194.     //
  195.     const char*       EvOcViewTitle();
  196.     void              EvOcViewSetTitle(const char far* title);
  197.  
  198.     bool              EvOcViewBorderSpaceReq(TRect far* rect);
  199.     bool              EvOcViewBorderSpaceSet(TRect far* rect);
  200.     bool              EvOcViewDrop(TOcDragDrop far& ddInfo);
  201.     bool              EvOcViewDrag(TOcDragDrop far& ddInfo);
  202.     bool              EvOcViewScroll(TOcScrollDir scrollDir);
  203.     bool              EvOcViewGetScale(TOcScaleFactor& scaleFactor);
  204.     bool              EvOcViewGetSiteRect(TRect far* rect);
  205.     bool              EvOcViewSetSiteRect(TRect far* rect);
  206.     bool              EvOcViewPartActivate(TOcPart& ocPart);
  207.     bool              EvOcViewPasteObject(TOcInitInfo& init);
  208.  
  209.     // Server specific messages
  210.     //
  211.     bool              EvOcPartInvalid(TOcPart far& /*part*/);
  212.     bool              EvOcViewSavePart(TOcSaveLoad far& ocSave);
  213.     bool              EvOcViewLoadPart(TOcSaveLoad far& ocLoad);
  214.     bool              EvOcViewPaint(TOcViewPaint far& vp);
  215.     bool              EvOcViewInsMenus(TOcMenuDescr far& sharedMenu);
  216.     bool              EvOcViewShowTools(TOcToolBarInfo far& tbi);
  217.     bool              EvOcViewGetPalette(LOGPALETTE far* far* palette);
  218.     bool              EvOcViewClipData(TOcFormatData far& format);
  219.     bool              EvOcViewSetData(TOcFormatData far& format);
  220.     bool              EvOcViewClose();
  221.     bool              EvOcViewPartSize(TOcPartSize far& size);
  222.     bool              EvOcViewOpenDoc(const char far* path);
  223.     bool              EvOcViewAttachWindow(bool attach);
  224.     bool              EvOcViewSetScale(TOcScaleFactor& scaleFactor);
  225.     bool              EvOcViewGetItemName(TOcItemName& item);
  226.     bool              EvOcViewSetLink(TOcLinkView& view);
  227.     bool              EvOcViewBreakLink(TOcLinkView& view);
  228.     bool              EvOcViewDoVerb(uint verb);
  229.  
  230.     virtual bool      EvOcViewTransformCoords(uint verb);
  231.  
  232. #if defined(BI_PLAT_WIN32)
  233.     // Ambient property specific messages
  234.     //
  235.     virtual bool      EvOcAmbientGetBackColor(long* rgb);
  236.     virtual bool      EvOcAmbientGetForeColor(long* rgb);
  237.     virtual bool      EvOcAmbientGetLocaleID(long* locale);
  238.     virtual bool      EvOcAmbientGetTextAlign(short* align);
  239.     virtual bool      EvOcAmbientGetMessageReflect(bool* msgReflect);
  240.     virtual bool      EvOcAmbientGetUserMode(bool* mode);
  241.     virtual bool      EvOcAmbientGetUIDead(bool* dead);
  242.     virtual bool      EvOcAmbientGetShowGrabHandles(bool* show);
  243.     virtual bool      EvOcAmbientGetShowHatching(bool* show);
  244.     virtual bool      EvOcAmbientGetDisplayAsDefault(bool* disp);
  245.     virtual bool      EvOcAmbientGetSupportsMnemonics(bool* support);
  246.     virtual bool      EvOcAmbientGetDisplayName(TString** name);
  247.     virtual bool      EvOcAmbientGetScaleUnits(TString** units);
  248.     virtual bool      EvOcAmbientGetFont(IDispatch** font);
  249.  
  250.     virtual bool      EvOcAmbientSetBackColor(long rgb);
  251.     virtual bool      EvOcAmbientSetForeColor(long rgb);
  252.     virtual bool      EvOcAmbientSetLocaleID(long locale);
  253.     virtual bool      EvOcAmbientSetTextAlign(short align);
  254.     virtual bool      EvOcAmbientSetMessageReflect(bool msgReflect);
  255.     virtual bool      EvOcAmbientSetUserMode(bool mode);
  256.     virtual bool      EvOcAmbientSetUIDead(bool dead);
  257.     virtual bool      EvOcAmbientSetShowGrabHandles(bool show);
  258.     virtual bool      EvOcAmbientSetShowHatching(bool show);
  259.     virtual bool      EvOcAmbientSetDisplayAsDefault(bool disp);
  260.     virtual bool      EvOcAmbientSetSupportsMnemonics(bool support);
  261.     virtual bool      EvOcAmbientSetDisplayName(TString* name);
  262.     virtual bool      EvOcAmbientSetScaleUnits(TString* units);
  263.     virtual bool      EvOcAmbientSetFont(IDispatch* font);
  264.  
  265.     // Ctrl event specific messages
  266.     //
  267.     virtual bool      EvOcCtrlClick(TCtrlEvent* pev);
  268.     virtual bool      EvOcCtrlDblClick(TCtrlEvent* pev);
  269.     virtual bool      EvOcCtrlMouseDown(TCtrlMouseEvent* pev);
  270.     virtual bool      EvOcCtrlMouseMove(TCtrlMouseEvent* pev);
  271.     virtual bool      EvOcCtrlMouseUp(TCtrlMouseEvent* pev);
  272.     virtual bool      EvOcCtrlKeyDown(TCtrlKeyEvent* pev);
  273.     virtual bool      EvOcCtrlKeyUp(TCtrlKeyEvent* pev);
  274.     virtual bool      EvOcCtrlErrorEvent(TCtrlErrorEvent* pev);
  275.     virtual bool      EvOcCtrlFocus(TCtrlFocusEvent* pev);
  276.     virtual bool      EvOcCtrlPropertyChange(TCtrlPropertyEvent* pev);
  277.     virtual bool      EvOcCtrlPropertyRequestEdit(TCtrlPropertyEvent* pev);
  278.     virtual bool      EvOcCtrlCustomEvent(TCtrlCustomEvent* pev);
  279. #endif
  280.  
  281.     TPopupMenu*       CreateVerbPopup(const TOcVerb& ocVerb);
  282.     void              EvDoVerb(uint whichVerb);
  283.     void              Init();
  284.  
  285.   protected:
  286.     TOcPart*          DragPart;
  287.     TUIHandle::TWhere DragHit;
  288.     TDC*              DragDC;
  289.     TPoint            DragPt;
  290.     TRect             DragRect;
  291.     TPoint            DragStart;
  292.     TOcScaleFactor    Scale;              // current scaling factor
  293.     TRect             Pos;                // current position
  294.  
  295.     TOcDocument*      OcDoc;              // associated OCF document partner
  296.     TOcView*          OcView;             // associated OCF view partner
  297.     TOcApp*           OcApp;              // associated OCF app partner
  298.     string            ContainerName;      // Name for this container
  299.  
  300.     bool              Remote;             // Using a remote OC view?
  301.     bool              ShowObjects;        // Show embedded part frames?
  302.  
  303.     int               MinWidth;           // minimum width of part
  304.     int               MinHeight;          // minimum height of part
  305.  
  306.   DECLARE_RESPONSE_TABLE(TOleWindow);
  307. };
  308.  
  309.  
  310. //
  311. // class TOleClientDC
  312. // ~~~~~ ~~~~~~~~~~~~
  313. // The TOleClientDC is a client dc with window origin, ext, and viewport
  314. // origin, ext, setup to reflect the current scrolling and scaling information.
  315. //
  316. class _USERCLASS TOleClientDC : public TClientDC {
  317.   public:
  318.     TOleClientDC(TOleWindow& win, bool scale = true);
  319. };
  320.  
  321. // Generic definitions/compiler options (eg. alignment) following the
  322. // definition of classes
  323. #include <services/posclass.h>
  324.  
  325. #if defined(BI_NAMESPACE)
  326. } // namespace OWL
  327. #endif
  328.  
  329. // --------------------------------------------------------------------------
  330. // Inline implementation
  331. //
  332.  
  333. //
  334. // Return pointer to TOcDocument helper object associated with this window
  335. //
  336. inline TOcDocument* TOleWindow::GetOcDoc() {
  337.   return OcDoc;
  338. }
  339.  
  340. //
  341. // Return pointer to the 'TOcView' helper object associated with this window
  342. //
  343. inline TOcView* TOleWindow::GetOcView() {
  344.   return OcView;
  345. }
  346.  
  347. //
  348. // Return pointer to 'TOcRemView' object associated with this window.
  349. // NOTE: Returns 0 in case of failure. For example, a TOleWindow of a
  350. //       container application does not have an associated 'TOcRemView'
  351. //       and will return 0.
  352. //
  353. inline TOcRemView* TOleWindow::GetOcRemView() {
  354.   return TYPESAFE_DOWNCAST(OcView, TOcRemView);
  355. }
  356.  
  357. //
  358. inline TOcApp* TOleWindow::GetOcApp() {
  359.   return OcApp;
  360. }
  361.  
  362. //
  363. inline bool TOleWindow::SelectEmbedded() {
  364.   return DragPart != 0;
  365. }
  366.  
  367. //
  368. inline bool TOleWindow::IsRemote() const {
  369.   return Remote;
  370. }
  371.  
  372. //
  373. inline bool TOleWindow::PaintSelection(TDC& dc, bool erase,
  374.                                        TRect& rect, void* userData) {
  375.   return false;
  376. }
  377.  
  378. //
  379. inline bool TOleWindow::PaintLink(TDC& dc, bool erase,
  380.                                   TRect& rect, TString& moniker) {
  381.   return false;
  382. }
  383.  
  384. //
  385. inline bool TOleWindow::EvOcPartInvalid(TOcPart far& /*part*/) {
  386.   return false;
  387. }
  388.  
  389. // on linking must be implemented and return the file name
  390. inline const char far* TOleWindow::GetFileName() {
  391.   return NULL;
  392. }
  393.  
  394. #endif
  395.